Excel BI - Excel Challenge 740

excel-challenges
excel-formulas
🔰 Count the number of blanks following alphabets and list count against alphabets.
Published

March 24, 2026

Illustration for Excel BI - Excel Challenge 740

Challenge Description

🔰 Count the number of blanks following alphabets and list count against alphabets.

Solutions

library(tidyverse)
library(readxl)

path = "Excel/700-799/740/740 Count Blanks.xlsx"
input = read_excel(path, sheet = "Sheet2", range = "A2:A40")
test = read_excel(path, sheet = "Sheet2", range = "B2:C10")

result = input %>%
  fill(Data) %>%
  summarise(`Blanks Count` = n() - 1, .by = Data)

all.equal(result$`Blank Counts`, test$`Blanks Count`)
# TRUE
  • Logic: Read the workbook ranges needed for the challenge; Aggregate or rank the data at the required grouping level.
  • Strengths: The code maps the workbook rule into a compact, reproducible pipeline.
  • Areas for Improvement: The solution assumes the workbook layout and selected ranges remain stable, so any structural change in the sheet would require small adjustments.
  • Gem: The elegant part is how little code is needed once the correct intermediate representation is chosen.
import pandas as pd

path = "700-799/740/740 Count Blanks.xlsx"
input = pd.read_excel(path, sheet_name="Sheet2", usecols="A", skiprows=1, nrows=39)
test = pd.read_excel(path, sheet_name="Sheet2", usecols="B:C", skiprows=1, nrows=8)

result = input.ffill().groupby('Data').size().sub(1).reset_index(name='Blanks Count')

print(result['Blanks Count'].equals(test['Blanks Count']))

The Python version follows the same grouped logic and keeps the transformation explicit in a dataframe pipeline.

Difficulty Level

Easy / Medium

The business rule is clear, though the workbook still needs a few transformation steps to reach the expected output.